package top.lidee.module.aggregat.controller;

import com.alipay.api.AlipayApiException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.lidee.framework.web.ResponseObject;
import top.lidee.module.aggregat.domain.AccessAliagent;
import top.lidee.module.aggregat.service.ClientAggregatService;


/**
 * 阿里产品开通授权接口
 */
@Api(tags="聚合支付-阿里产品开通授权接口")
@RestController
@AllArgsConstructor
@RequestMapping(value = "/alipayproduct/authorize")
public class AlipayProductsAuthController {

    @Autowired
    private ClientAggregatService aggregatService;

    /**
     * 支付宝代签当面付产品
     * */
    @ApiOperation(value = "支付宝代签面对面产品")
    @RequestMapping(value = "/alipay/facetoface/{storeId}/{userId}", method = RequestMethod.POST)
    @CrossOrigin
    public ResponseObject aliPayFacetoface(@PathVariable @NonNull Integer storeId,@PathVariable @NonNull String userId) throws AlipayApiException {
        return aggregatService.aliOpenFacetoface(storeId,userId);
    }

    /**
     * 支付宝代签产品通用接口
     * */
    @ApiOperation(value = "支付宝代签产品通用接口")
    @RequestMapping(value = "/alipay/openProducts", method = RequestMethod.POST)
    @CrossOrigin
    public ResponseObject alipayopenProducts(@RequestBody AccessAliagent aliagent) throws AlipayApiException {
        return aggregatService.aliOpenProducts(aliagent);
    }




    /**
     *支付宝查询商户某个产品的签约状态
     * 传入产品的码值
     * */
    @ApiOperation(value = "支付宝查询商户某个产品的签约状态")
    @RequestMapping(value = "/alipay/statusQuery/{pid}/{productCodes}", method = RequestMethod.GET)
    @CrossOrigin
    public ResponseObject alipaystatusQuery(@PathVariable String pid, @PathVariable String productCodes) throws AlipayApiException {
        return aggregatService.statusQuery(pid,productCodes);
    }























}
